using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_HeroSkillCell : UIBaseNode
    {

        #region Template Generate,don't modify
        protected partial class UIB_UIN_HeroSkillCell
        {
            #region ObjectBinding Generate
            public IQIGame.Onigao.Framework.ExText name { protected set; get; }
            public IQIGame.Onigao.Framework.ExImage icon { protected set; get; }
            public IQIGame.Onigao.Framework.ExText lv { protected set; get; }
            public UnityEngine.GameObject empty { protected set; get; }
            public UnityEngine.GameObject lockRoot { protected set; get; }
            public UnityEngine.GameObject lvRoot { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("name", out var __tbv0);
                this.name = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("icon", out var __tbv1);
                this.icon = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("lv", out var __tbv2);
                this.lv = __tbv2;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("empty", out var __tbv3);
                this.empty = __tbv3;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("lockRoot", out var __tbv4);
                this.lockRoot = __tbv4;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("lvRoot", out var __tbv5);
                this.lvRoot = __tbv5;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields & properties
        protected UIB_UIN_HeroSkillCell ui { get; set; }
        #endregion

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_HeroSkillCell();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        protected override void OnDispose()
        {
        }

        public void Show(SkillBaseData skillData)
        {
            if (skillData == null)
                return;
            this.Show();
            this.ui.lv.text = APIUIConst.GetGreaterAddStr(skillData.lv);
            this.ui.lvRoot.SetActive(skillData.lv > 1);
            var cfgSkill = skillData.cfgData;
            this.SetImageSprite(this.ui.icon, cfgSkill.Icon_fullPath);
            this.ui.lockRoot.SetActive(!skillData.isUnlock);
            this.ShowName("");
        }

        public void ShowName(string name)
        {
            this.ui.name.text = name;
        }
    }
}
